package com.example.app.controller

import com.example.app.dao.UserRepository
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody

@RestController
@RequestMapping(value = ["/api"])
class UserController {

    @Autowired
    var userRepository: UserRepository? = null

    @GetMapping("/login")
    @ResponseBody
    fun login(name: String, pwd: String): String {
        val user = userRepository!!.findByName(name)
        if (pwd == user.psd) {
            return "0"
        }
        return "用户名或密码错误！"
    }

}